class Solution:
    def rotate(self, matrix):
        """
        Do not return anything, modify matrix in-place instead.
        """
        len_matrix = len(matrix)
        max_i, mid_num = (len_matrix + 1) // 2, len_matrix-1
        if len_matrix % 2 == 0:
            max_h = (len_matrix + 1) // 2
        else:
            max_h = len_matrix // 2
        for i in range(max_i):
            for h in range(max_h):
                matrix[i][h], matrix[h][mid_num-i], matrix[mid_num-i][mid_num-h], matrix[mid_num-h][i] = \
                matrix[mid_num-h][i], matrix[i][h], matrix[h][mid_num-i], matrix[mid_num-i][mid_num-h]


a = Solution()
b = [
  [ 5, 1, 9,11],
  [ 2, 4, 8,10],
  [13, 3, 6, 7],
  [15,14,12,16]
]
a.rotate(b)
print(b)